/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bs.forms;

import com.bs.beans.Lancamento;
import java.util.Date;

/**
 *
 * @author Bone
 */
public class LancamentoForm extends DialogoForm{

    public LancamentoForm() {
        super();
        initComponents();
        incluirFormButton.setVisible(false);
        concluirFormButton.setVisible(false);
        iniciarDados();
    }

    public LancamentoForm(Object bean) {
        super(bean);
        initComponents();
        incluirFormButton.setVisible(false);
        concluirFormButton.setVisible(false);
        iniciarDados();
    }
    public LancamentoForm(Object bean, boolean entrada) {
        super(bean);
        initComponents();
        entradaCheck.setSelected(entrada);
        entradaCheck.setVisible(false);
        iniciarDados();
    }

    public void concluir(){
        Lancamento l = formularioController.getBean();
        ConcluirContaForm c = new ConcluirContaForm();
        Date dataPag = c.getValor();
        if(dataPag == null){
            return;
        }
        l.setDataPagamento(dataPag);
        l.setConcluido(Short.parseShort("1"));
        if(l.getId() != null){
            entityManager.alterar(l);
        }else{
            entityManager.inserir(l);
        }
        setVisible(false);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        bindingGroup = new org.jdesktop.beansbinding.BindingGroup();

        formularioController = new com.bs.extensoesSwing.FormularioController<com.bs.beans.Lancamento>();
        entityManager = new com.bs.persistencia.EntityManager();
        pessoa = new com.bs.beans.Pessoa();
        booleanConverter = new com.bs.converters.ConversorBoolean();
        conversorData = new com.bs.converters.ConversorData();
        conversorMonetario = new com.bs.converters.ConversorMonetario();
        tituloFormulario = new com.bs.extensoesSwing.TituloFormulario();
        excluirFormButton = new com.bs.extensoesSwing.ExcluirFormButton();
        cancelarFormButton = new com.bs.extensoesSwing.CancelarFormButton();
        incluirFormButton = new com.bs.extensoesSwing.IncluirFormButton();
        alterarFormButton = new com.bs.extensoesSwing.AlterarFormButton();
        campoData1 = new com.bs.extensoesSwing.CampoData();
        jLabel1 = new javax.swing.JLabel();
        campoData2 = new com.bs.extensoesSwing.CampoData();
        jLabel2 = new javax.swing.JLabel();
        entradaCheck = new javax.swing.JCheckBox();
        campoSugestao1 = new com.bs.extensoesSwing.CampoSugestao();
        jLabel3 = new javax.swing.JLabel();
        campoSugestao2 = new com.bs.extensoesSwing.CampoSugestao();
        jLabel4 = new javax.swing.JLabel();
        campoTexto1 = new com.bs.extensoesSwing.CampoTexto();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        campoSugestao3 = new com.bs.extensoesSwing.CampoSugestao();
        jLabel7 = new javax.swing.JLabel();
        campoMonetario1 = new com.bs.extensoesSwing.CampoMonetario();
        jLabel8 = new javax.swing.JLabel();
        campoMonetario2 = new com.bs.extensoesSwing.CampoMonetario();
        campoMonetario3 = new com.bs.extensoesSwing.CampoMonetario();
        jLabel9 = new javax.swing.JLabel();
        jSeparator1 = new javax.swing.JSeparator();
        jLabel10 = new javax.swing.JLabel();
        campoTexto2 = new com.bs.extensoesSwing.CampoTexto();
        concluirFormButton = new javax.swing.JButton();

        formularioController.setEntityManager(entityManager);
        formularioController.setJanela(this);

        org.jdesktop.beansbinding.Binding binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${bean}"), formularioController, org.jdesktop.beansbinding.BeanProperty.create("bean"));
        binding.setSourceNullValue(null);
        binding.setSourceUnreadableValue(null);
        bindingGroup.addBinding(binding);

        tituloFormulario.setTitulo("Cadastro de lançamento");

        excluirFormButton.setController(formularioController);

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, formularioController, org.jdesktop.beansbinding.ELProperty.create("${bean.id != null}"), excluirFormButton, org.jdesktop.beansbinding.BeanProperty.create("enabled"));
        bindingGroup.addBinding(binding);

        cancelarFormButton.setController(formularioController);

        incluirFormButton.setController(formularioController);

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, formularioController, org.jdesktop.beansbinding.ELProperty.create("${bean.id == null}"), incluirFormButton, org.jdesktop.beansbinding.BeanProperty.create("enabled"));
        bindingGroup.addBinding(binding);

        alterarFormButton.setController(formularioController);

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, formularioController, org.jdesktop.beansbinding.ELProperty.create("${bean.id != null}"), alterarFormButton, org.jdesktop.beansbinding.BeanProperty.create("enabled"));
        bindingGroup.addBinding(binding);

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, formularioController, org.jdesktop.beansbinding.ELProperty.create("${bean.dataVencimento}"), campoData1, org.jdesktop.beansbinding.BeanProperty.create("text_ON_ACTION_OR_FOCUS_LOST"));
        binding.setSourceNullValue(null);
        binding.setSourceUnreadableValue(null);
        binding.setConverter(conversorData);
        bindingGroup.addBinding(binding);

        jLabel1.setText("Vencimento:");

        campoData2.setEnabled(false);

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, formularioController, org.jdesktop.beansbinding.ELProperty.create("${bean.dataPagamento}"), campoData2, org.jdesktop.beansbinding.BeanProperty.create("text_ON_ACTION_OR_FOCUS_LOST"));
        binding.setSourceNullValue(null);
        binding.setSourceUnreadableValue(null);
        binding.setConverter(conversorData);
        bindingGroup.addBinding(binding);

        jLabel2.setText("Pagamento:");

        entradaCheck.setText("Entrada");
        entradaCheck.setEnabled(false);

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, formularioController, org.jdesktop.beansbinding.ELProperty.create("${bean.entrada}"), entradaCheck, org.jdesktop.beansbinding.BeanProperty.create("selected"));
        binding.setSourceNullValue(false);
        binding.setSourceUnreadableValue(false);
        binding.setConverter(booleanConverter);
        bindingGroup.addBinding(binding);

        campoSugestao1.setCampo("descricao");
        campoSugestao1.setCampoRetorno("id");
        campoSugestao1.setEntityManager(entityManager);
        campoSugestao1.setParametro("parametro");
        campoSugestao1.setsQuery("SELECT t FROM TipoLancamento t WHERE t.descricao LIKE :parametro");

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, formularioController, org.jdesktop.beansbinding.ELProperty.create("${bean.tipo}"), campoSugestao1, org.jdesktop.beansbinding.BeanProperty.create("itemSelecionado"));
        binding.setSourceNullValue(null);
        binding.setSourceUnreadableValue(null);
        bindingGroup.addBinding(binding);

        jLabel3.setText("Tipo:");

        campoSugestao2.setCampo("descricao");
        campoSugestao2.setCampoRetorno("id");
        campoSugestao2.setEntityManager(entityManager);
        campoSugestao2.setParametro("parametro");
        campoSugestao2.setsQuery("SELECT c FROM Conta c WHERE c.descricao LIKE :parametro");

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, formularioController, org.jdesktop.beansbinding.ELProperty.create("${bean.conta}"), campoSugestao2, org.jdesktop.beansbinding.BeanProperty.create("itemSelecionado"));
        binding.setSourceNullValue(null);
        binding.setSourceUnreadableValue(null);
        bindingGroup.addBinding(binding);

        jLabel4.setText("Conta:");

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, formularioController, org.jdesktop.beansbinding.ELProperty.create("${bean.documento}"), campoTexto1, org.jdesktop.beansbinding.BeanProperty.create("text"));
        binding.setSourceNullValue(null);
        binding.setSourceUnreadableValue(null);
        bindingGroup.addBinding(binding);

        jLabel5.setText("Documento:");

        jLabel6.setText("Pessoa:");

        campoSugestao3.setCampo("razaoSocial");
        campoSugestao3.setCampoRetorno("id");
        campoSugestao3.setEntityManager(entityManager);
        campoSugestao3.setParametro("parametro");
        campoSugestao3.setsQuery("SELECT p FROM Pessoa p WHERE p.razaoSocial LIKE :parametro");

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, formularioController, org.jdesktop.beansbinding.ELProperty.create("${bean.pessoa}"), campoSugestao3, org.jdesktop.beansbinding.BeanProperty.create("itemSelecionado"));
        binding.setSourceUnreadableValue(null);
        bindingGroup.addBinding(binding);

        jLabel7.setText("Valor:");

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, formularioController, org.jdesktop.beansbinding.ELProperty.create("${bean.valor}"), campoMonetario1, org.jdesktop.beansbinding.BeanProperty.create("text"));
        binding.setSourceNullValue(null);
        binding.setSourceUnreadableValue(null);
        binding.setConverter(conversorMonetario);
        bindingGroup.addBinding(binding);

        jLabel8.setText("Juros:");

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, formularioController, org.jdesktop.beansbinding.ELProperty.create("${bean.juros}"), campoMonetario2, org.jdesktop.beansbinding.BeanProperty.create("text"));
        binding.setSourceNullValue(null);
        binding.setSourceUnreadableValue(null);
        binding.setConverter(conversorMonetario);
        bindingGroup.addBinding(binding);

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, formularioController, org.jdesktop.beansbinding.ELProperty.create("${bean.desconto}"), campoMonetario3, org.jdesktop.beansbinding.BeanProperty.create("text"));
        binding.setSourceNullValue(null);
        binding.setSourceUnreadableValue(null);
        binding.setConverter(conversorMonetario);
        bindingGroup.addBinding(binding);

        jLabel9.setText("Desconto:");

        jLabel10.setText("Observação:");

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, formularioController, org.jdesktop.beansbinding.ELProperty.create("${bean.observacao}"), campoTexto2, org.jdesktop.beansbinding.BeanProperty.create("text"));
        binding.setSourceNullValue(null);
        binding.setSourceUnreadableValue(null);
        bindingGroup.addBinding(binding);

        concluirFormButton.setText("Concluir");
        concluirFormButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                concluirFormButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(tituloFormulario, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(0, 0, Short.MAX_VALUE)
                                .addComponent(concluirFormButton)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(incluirFormButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(alterarFormButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                        .addComponent(jLabel3)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(campoSugestao1, javax.swing.GroupLayout.PREFERRED_SIZE, 403, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                        .addComponent(jLabel1)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(campoData1, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(18, 18, 18)
                                        .addComponent(jLabel2)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(campoData2, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(18, 18, 18)
                                        .addComponent(entradaCheck))
                                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                        .addComponent(jLabel4)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(campoSugestao2, javax.swing.GroupLayout.PREFERRED_SIZE, 409, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                .addGap(0, 0, Short.MAX_VALUE)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(excluirFormButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cancelarFormButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel5)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(campoTexto1, javax.swing.GroupLayout.PREFERRED_SIZE, 174, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel6)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(campoSugestao3, javax.swing.GroupLayout.PREFERRED_SIZE, 429, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel7)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(campoMonetario1, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(jLabel8)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(campoMonetario2, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(jLabel9)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(campoMonetario3, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel10)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(campoTexto2, javax.swing.GroupLayout.PREFERRED_SIZE, 463, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
            .addComponent(jSeparator1)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(tituloFormulario, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(5, 5, 5)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(campoData1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2)
                    .addComponent(campoData2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(entradaCheck))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(campoSugestao1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(campoSugestao2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(campoTexto1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel5))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(campoSugestao3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel6))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(campoMonetario1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel8)
                    .addComponent(campoMonetario2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel9)
                    .addComponent(campoMonetario3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel10)
                    .addComponent(campoTexto2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(excluirFormButton, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cancelarFormButton, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(incluirFormButton, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(alterarFormButton, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(concluirFormButton, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        bindingGroup.bind();

        pack();
        setLocationRelativeTo(null);
    }// </editor-fold>//GEN-END:initComponents

    private void concluirFormButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_concluirFormButtonActionPerformed
        Lancamento l = formularioController.getBean();
        ConcluirContaForm c = new ConcluirContaForm();
        Date dataPag = c.getValor();
        if(dataPag == null){
            return;
        }
        l.setDataPagamento(dataPag);
        l.setConcluido(Short.parseShort("1"));
        if(!entityManager.getTransaction().isActive()){
            entityManager.getTransaction().begin();
        }
        if(l.getId() != null){
            entityManager.alterar(l);
        }else{
            entityManager.inserir(l);
        }
        entityManager.getTransaction().commit();
        entityManager.flush();
        setVisible(false);
    }//GEN-LAST:event_concluirFormButtonActionPerformed

   
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private com.bs.extensoesSwing.AlterarFormButton alterarFormButton;
    private com.bs.converters.ConversorBoolean booleanConverter;
    private com.bs.extensoesSwing.CampoData campoData1;
    private com.bs.extensoesSwing.CampoData campoData2;
    private com.bs.extensoesSwing.CampoMonetario campoMonetario1;
    private com.bs.extensoesSwing.CampoMonetario campoMonetario2;
    private com.bs.extensoesSwing.CampoMonetario campoMonetario3;
    private com.bs.extensoesSwing.CampoSugestao campoSugestao1;
    private com.bs.extensoesSwing.CampoSugestao campoSugestao2;
    private com.bs.extensoesSwing.CampoSugestao campoSugestao3;
    private com.bs.extensoesSwing.CampoTexto campoTexto1;
    private com.bs.extensoesSwing.CampoTexto campoTexto2;
    private com.bs.extensoesSwing.CancelarFormButton cancelarFormButton;
    private javax.swing.JButton concluirFormButton;
    private com.bs.converters.ConversorData conversorData;
    private com.bs.converters.ConversorMonetario conversorMonetario;
    private com.bs.persistencia.EntityManager entityManager;
    private javax.swing.JCheckBox entradaCheck;
    private com.bs.extensoesSwing.ExcluirFormButton excluirFormButton;
    private com.bs.extensoesSwing.FormularioController<com.bs.beans.Lancamento> formularioController;
    private com.bs.extensoesSwing.IncluirFormButton incluirFormButton;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JSeparator jSeparator1;
    private com.bs.beans.Pessoa pessoa;
    private com.bs.extensoesSwing.TituloFormulario tituloFormulario;
    private org.jdesktop.beansbinding.BindingGroup bindingGroup;
    // End of variables declaration//GEN-END:variables

    
    
    
    private void iniciarDados() {
        Lancamento l = formularioController.getBean();
        if(l != null){
            if(l.getId() == null){
                l.setDataLancamento(new Date());
                l.setConcluido(Short.parseShort("0"));
            }
        }
    }

    @Override
    public void setBean(Object bean) {
        super.setBean(bean); //To change body of generated methods, choose Tools | Templates.
        iniciarDados();
    }
    
}
